package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import java.util.Date;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.*;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Null;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author shihu
 * @mail m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(name = "运行记录Po")
public class ModuleRunPo extends BasePo{
  @NotNull(groups = {IUpdateVo.class}, message = "id不能为空")
  @Schema(name = "主键")
  private Long id;

  @NotNull(groups = {IInsertVo.class},message = "项目id不能为空")
  @Schema(name = "项目id")
  private Long projectId;

  @NotNull(groups = {IInsertVo.class},message = "模块id不能为空")
  @Schema(name = "模块id")
  private Long moduleId;

  @NotNull(groups = {IInsertVo.class},message = "构建记录id不能为空")
  @Schema(name = "构建记录id")
  private Long moduleBuildId;

  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 200, message = "tags长度范围最大200")
  @Schema(name = "标签编码")
  private String tags;

  @NotNull(groups = {IInsertVo.class},message = "操作类型不能为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 20, message = "operation长度范围最大20")
  @Schema(name = "操作类型")
  private String operation;

  @Schema(name = "租户")
  private Long tenantId;

  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(name = "创建时间")
  private Date createTime;

  @NotNull(groups = {IInsertVo.class},message = "创建用户ID不能为空")
  @Schema(name = "创建用户ID")
  private Long createrId;

  @NotNull(groups = {IInsertVo.class},message = "创建用户名不能为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 20, message = "createrName长度范围最大20")
  @Schema(name = "创建用户名")
  private String createrName;



  public void initLoginAccount(ILoginAccount loginAccount){
    this.tenantId = loginAccount.getTenantId();
    this.createrId = loginAccount.getId();
    this.createrName = loginAccount.getAccount();
  }
}



